package com.ruoyi.web.group.matches.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.group.matches.entity.Matches;
import com.ruoyi.web.group.matches.service.MatchesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 比赛信息控制器
 */
@RestController
@RequestMapping("matches")
public class MatchesController {
    @Autowired
    private MatchesService matchesService;

    /**
     * 添加赛事信息
     * @param id
     * @return
     */
    @GetMapping("del")
    public AjaxResult del(@RequestParam Integer id){

        if(id != null &&  matchesService.removeById(id)){
            return AjaxResult.success("操作成功");
        }
        return AjaxResult.error("操作失败");
    }

    /**
     * 添加赛事信息
     * @param matches
     * @return
     */
    @PostMapping("add")
    public AjaxResult add(@RequestBody Matches matches){

        if(matches != null &&  matchesService.save(matches)){
            return AjaxResult.success("操作成功");
        }
        return AjaxResult.error("操作失败");
    }

    /**
     * 修改赛事信息
     * @param matches
     * @return
     */
    @PostMapping("update")
    public AjaxResult upd(@RequestBody Matches matches){

        if(matches != null &&  matchesService.updateById(matches)){
            return AjaxResult.success("操作成功");
        }
        return AjaxResult.error("操作失败");

    }

    /**
     * 查询比赛列表

     * @return
     */
    @GetMapping("findList")
    public AjaxResult findList( Matches matches){
        return AjaxResult.success(matchesService.findList(matches));
    }
}
